package org.jeecg.modules.demo.crm.service.impl;

import org.jeecg.modules.demo.crm.entity.CBankInfo;
import org.jeecg.modules.demo.crm.entity.CContractorInfo;
import org.jeecg.modules.demo.crm.mapper.CBankInfoMapper;
import org.jeecg.modules.demo.crm.mapper.CContractorInfoMapper;
import org.jeecg.modules.demo.crm.service.ICContractorInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 分包商信息表
 * @Author: jeecg-boot
 * @Date:   2025-05-31
 * @Version: V1.0
 */
@Service
public class CContractorInfoServiceImpl extends ServiceImpl<CContractorInfoMapper, CContractorInfo> implements ICContractorInfoService {

    @Autowired
    private CContractorInfoMapper cContractorInfoMapper;

    @Autowired
    private CBankInfoMapper cBankInfoMapper;

    @Override
    public void install(CContractorInfo cContractorInfo) {
        List<CBankInfo> bankInfoList = cBankInfoMapper.findByContractorId(cContractorInfo.getId());
        cContractorInfo.setId(null);
        cContractorInfoMapper.insert(cContractorInfo);
        for (CBankInfo cBankInfo : bankInfoList) {
            cBankInfo.setContactId(cContractorInfo.getId());
            cBankInfoMapper.updateById(cBankInfo);
        }
    }
}
